package com.zhangmengyuan.medical.service.impl;


import com.zhangmengyuan.medical.dao.GoodsDao;
import com.zhangmengyuan.medical.entity.Goods;
import com.zhangmengyuan.medical.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsDao goodsDao;

    @Override
    public void save(Goods goods) {
        goodsDao.save(goods);
    }

    @Override
    public Page<Goods> getAll(int page) {
        Pageable pageable = new PageRequest(page, 10);
        return goodsDao.findAll(pageable);
    }

    @Override
    public Goods getById(Integer goodsId) {
        return goodsDao.findOne(goodsId);
    }
}
